    let time = null;
    class Banner {
        //如果某些元素在该类中被修改，需要将元素当做参数传进来
        constructor(newBox, newLi) {
            this.index = 0;
            this.box = newBox;
            this.oLis = newLi;

            this.box.style.backgroundImage =`url(../img/lunbo/${this.index}.jpg)`;
            this.oLis[this.index].style.backgroundColor = "gray";
            this.eventBind();

        }

        //工具函数：设置box背景颜色
        setBoxBgc() {
            this.box.style.backgroundImage = `url(../img/lunbo/${this.index}.jpg)`;
        }

        //工具函数：设置li颜色
        setLiColor() {
            for (let i = 0; i < this.oLis.length; i++) {
                if (this.index == i) {
                    this.oLis[i].style.backgroundColor = "gray";
                } else {
                    this.oLis[i].style.backgroundColor = "transparent";
                }
            }
        }
        next() {
            let oNext = document.querySelector("#btn-next");
            let that = this;
            oNext.onclick = function() {
                that.index++;

                if (that.index == that.oLis.length) {
                    that.index = 0;
                }
                that.setBoxBgc();
                that.setLiColor();
            }
        }
        prev() {
            let oPrev = document.querySelector("#btn-previous");
            let that = this;
            oPrev.onclick = function() {
                that.index--;
                if (that.index == -1) {
                    that.index = that.oLis.length - 1;
                }
                that.setBoxBgc();
                that.setLiColor();
            }
        }

        Iterval() {
            let that = this;
            time = setInterval(function() {
                that.index++;
                if (that.index == oLis.length) {
                    that.index = 0;
                }
                that.setBoxBgc();
                that.setLiColor();
            }, 2000)

        }
        stop() {
            clearInterval(time);
        }
        clickLi() {
            let that = this;
            for (let i = 0; i < this.oLis.length; i++) {
                this.oLis[i].onclick = function() {
                    that.index = i;
                    that.setBoxBgc();
                    that.setLiColor();
                }
            }
            oImg.onmouseover = function() {
                that.stop();
            }
            oImg.onmouseout = function() {
                that.Iterval();
            }
        }
        eventBind() {
            this.next();
            this.prev();
            this.clickLi();
            this.Iterval();
        }

    }